<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>文章详情 - 可漾官网</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="keywords" content="可漾  可漾官网   可漾红豆薏米水  可漾五红汤  可漾红豆水  可漾绿豆水  可漾牛蒡茶  可漾产品  山东可漾饮料有限公司" />
    <meta http-equiv="description"
      content="山东可漾饮料有限公司在以红豆薏米水为代表的谷物饮品方面已经形成了完善的研发、生产和销售体系，并申请了红豆水萃取提纯技术专利，产品一经上市便热销全网。其中抖音、淘宝平台销售额在同类产品中遥遥领先。" />
    <meta name="keywords" content="可漾  可漾官网   可漾红豆薏米水  可漾五红汤  可漾红豆水  可漾绿豆水  可漾牛蒡茶  可漾产品  山东可漾饮料有限公司" />
    <meta name="description"
      content="山东可漾饮料有限公司在以红豆薏米水为代表的谷物饮品方面已经形成了完善的研发、生产和销售体系，并申请了红豆水萃取提纯技术专利，产品一经上市便热销全网。其中抖音、淘宝平台销售额在同类产品中遥遥领先。" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
    <link rel="bookmark" href="../favicon.ico" />
    <meta name="viewport" content="user-scalable=yes, width=device-width, initial-scale=0.5">
    <link rel="stylesheet" href="../static/css/main.css">
    <link rel="stylesheet" href="../static/css/header.css">
    <link rel="stylesheet" href="../static/css/detail.min.css">
    <link rel="stylesheet" href="../static/css/footer.min.css">
    <link rel="stylesheet" href="../static/libs/video-js.css">
  </head>
  <header>
    <div class="nav-box">
      <div id="logo" class="fl">
        <a href="../index.html"><img src="../static/images/Logo.png" alt="可漾"></a>
      </div>
      <ul class="nav fl clear">
        <a href="../index.html" class="nav-item nav-item1">首页</a>
        <a href="./about.html" class="nav-item">关于我们</a>  
        <span class="nav-item-wrap">
          <a href="./product.html" class="nav-item">
            <span class="nav-span">可漾产品</span>
          </a>
          <ul class="nav-list nav-list-prod">
            <!-- <li class="nav-li">红豆薏米水</li>
            <li class="nav-li">绿豆水</li>
            <li class="nav-li">五红汤</li>
            <li class="nav-li">红豆水</li>
            <li class="nav-li">红豆牛蒡茶</li> -->
          </ul>
        </span>  
        <span class="nav-item-wrap nav-item-wrap2">
          <a href="./brandnew.html" class="nav-item">
            <span class="nav-span">企业动态</span>
          </a>
          <ul class="nav-list nav-list2 nav-list-dynamic">
            <li class="nav-li">
              <a href="./brandnew.html">品牌新闻</a>
            </li>
            <li class="nav-li">
              <a href="./enterpriseactivity.html">企业活动</a>
            </li>
            <li class="nav-li">
              <a href="./wonderfulmoment.html">精彩瞬间</a>
            </li>
          </ul>
        </span>
        <a href="./join.html" class="nav-item">加入我们</a>  
      </ul>
    </div>
  </header>
  <main>
    <h1 class="title">健康饮品新趋势！瓶装红豆薏米水开启轻养生时代</h1>
    <p class="info-box">
      <span class="info"><a class="source" href="#"></a></span>
      <span class="gap"></span>
      <span class="info">发布时间：<span class="publish-time"></span></span>
    </p>
    <article id="articleDetail"></article>
  </main>
  <!-- 底部区域 -->
  <footer>
    <div class="footer flex">
      <ul class="link-box flex">
      <li>
        <h3>关于我们</h3>
        <p><a href="./about.html#about-box">企业介绍</a></p>
        <p><a href="./about.html#mission-box">企业使命</a></p>
        <p><a href="./about.html#roadmap">企业发展</a></p>
      </li>
      <li class="footer-prod-list">
        <!-- <h3>可漾产品</h3>
        <p><a href="#">红豆薏米水</a></p>
        <p><a href="#">绿豆水</a></p>
        <p><a href="#">五红汤</a></p>
        <p><a href="#">红豆水</a></p>
        <p><a href="#">红豆牛蒡茶</a></p> -->
      </li>
      <li>
        <h3>企业动态</h3>
        <p><a href="./brandnew.html">品牌新闻</a></p>
        <p><a href="./enterpriseactivity.html">企业活动</a></p>
        <p><a href="./wonderfulmoment.html">精彩瞬间</a></p>
      </li>
      <li>
        <h3>加入我们</h3>
        <p><a href="./join.html">未来展望</a></p>
        <p><a href="./join.html">招商加盟</a></p>
      </li>
    </ul>
    <ul class="addr-box">
      <h2>怕湿气，喝可漾</h2>
      <p>山东可漾饮料有限公司</p>
      <p>售后服务热线：4006279199</p>
      <p>地址：山东省潍坊市坊子区黄旗堡街办一马路</p>
      <ul class="feedback flex-start">
        <li class="qr">
          <img src="../static/images/qrcode.png" alt="">
          <span>关注微信公众号</span>
          <img class="qrcode-scan" src="../static/images/qrcode-scan.png" alt="">
        </li>
        <!-- <li class="email">
          <img src="../static/images/email.png" alt="">
          <span>投诉意见</span>
          <div class="email-feed">
            邮箱：<a href="mailto:qdcsx@163.com">qdcsx@163.com</a>
          </div>
        </li> -->
      </ul>
    </ul>
    </div>
    <div class="right"><a href="https://beian.miit.gov.cn/#/Integrated/index">鲁ICP备19040840号-1</a></div>
  </footer>
  <script src="../static/js/master.js"></script>
  <script src="../static/libs/jquery-1.10.1.min.js"></script>
  <script>
    var baseUrl = 'http://guanwang.keyangyinliao.com/api';
    $(function() {
      // 先从url中获取id 然后根据id获取详情
      var urlParam = window.location.search.substr(1),
        urlId = '',
        articleContent = '';
      
      if (urlParam) {
        urlId = getUrlParam(urlParam, "id");

        // 获取详情
        getArticleFromId(urlId);
      } else  {
        window.location.href = "../index.html"
      }

      // 文章来源于那个分类
      var categorySource = getUrlParam(urlParam, 'category');
      var categoryLink = goBackCategorylist(categorySource);
      $('.source').text(categorySource);
      $('.source').click(function() {
        window.location.href = categoryLink;
      })

    var baseUrl = 'http://guanwang.keyangyinliao.com/api';
    // 商品列表
      var prodListData = [];
      getProdList();
      function getProdList() {
        $.ajax({
          url: baseUrl + '/ad',
          type: 'get',
          dataType: 'json',
          success: function (res) {
            if (res.code !== 200) return;
            prodListData = res.data;
            initNavProds()
          }
        })
      }

      function initNavProds() {
        var prodListHeadSubHtml = '',
        footerProdListHtml = '<h3>可漾产品</h3>';

        $.each(prodListData, function(i) {
          prodListHeadSubHtml += '<li class="nav-li" data-id=' + prodListData[i].id + '>' + prodListData[i].title + '</li>'
        
          footerProdListHtml += '<p><a href="./product.html?id=' + prodListData[i].id + '">' + prodListData[i].title + '</a></p>';
        })


        // 头部导航[产品]下的【子产品】导航
        $('.nav-list-prod').append(prodListHeadSubHtml);
        $('.nav-list-prod .nav-li').each(function(i) {
          $(this).click(function() {
            window.location.href = './product.html?id=' + $(this).attr('data-id');
          })
        })

        // footer里的产品信息
        $('.footer-prod-list').append(footerProdListHtml);
      }
    })
    
    // 根据id获取文章内容
    function getArticleFromId(id) {
      $.ajax({
        url: baseUrl + '/article/get?id=' + id,
        type: 'get',
        dataType: 'json',
        success: function (res) {
          if (res.code !== 200) return;
          articleContent = rebuildArticleContent(res.data);

          $('.title').text(articleContent.title);
          // 把文章标题设置成当前网页title
          $('title').text(articleContent.title);
          $('.publish-time').text(articleContent.updated_at);
          $('article').html(articleContent.content);
        }
      })
    }

    function rebuildArticleContent(data) {
      var content = data.content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, '<img style="max-width:100%;height:auto" src="' + '$1' + '" />')
      .replace(/<video [^>]*src=['"]([^'"]+)[^>]*>/gi, '<video style="max-width:100% !important;height:auto" src="' + '$1' + '" controls/>')
      // 替换掉首行开头的空格
      .replace(/&nbsp;/ig, '');
      
      data.content = content;
      return data;
    }

    function goBackCategorylist(category) {
      var pageLink = ''
      switch (category) {
        case '可漾产品':
          pageLink = './product.html';
          break;
        case '企业动态':
          pageLink = '../index.html';
          break;
        case '品牌新闻':
          pageLink = './brandnew.html';
          break;
        case '企业活动':
          pageLink = './enterpriseactivity.html';
          break;
        case '精彩瞬间':
          pageLink = './wonderfulmoment.html';
          break;
        case '关于我们':
          pageLink = './about.html';
          break;
        default:
          break;
      }
      return pageLink;
    }

    // 从url中拿参数
    function getUrlParam(paramsString, key) {
      var value = '';
      var paramsArray = paramsString.split('&');
      for(var i=0;i<paramsArray.length;i++){
          var param = paramsArray[i].split("=");
          if(param[0] == key){
            value = decodeURIComponent(param[1])
            break;
          }
      }
      return value;
    }
  </script>
</html>